﻿using System;
using RibbonLib.Interop;

namespace todo.Ribbon
{
    public class RibbonButton : RibbonControl
    {
        public event EventHandler OnClick;

        public void FireOnClick(EventArgs e)
        {
            var handler = OnClick;
            if (handler != null) handler(this, e);
        }

        public RibbonButton(RibbonUI ribbonUI, uint commandID) : base(ribbonUI, commandID)
        {
            Console.WriteLine(".");
        }

        public override HRESULT Execute(ExecutionVerb verb, PropertyKeyRef key,
                                        PropVariantRef currentValue,
                                        IUISimplePropertySet commandExecutionProperties)
        {
            if (verb == ExecutionVerb.Execute)
            {
                FireOnClick(EventArgs.Empty);
            }
            return HRESULT.S_OK;
        }
    }
}